package com.appspot.didit.client;

import com.google.gwt.user.client.ui.*;

public class MainView extends Composite implements MainPresenter.View {
	
	final DecoratedTabPanel panel;
	final DecoratedTabPanel tabPanel;
	final DialogBox db;
	
	public MainView() {
		
    	panel = new DecoratedTabPanel();
    	
        db = new DialogBox();
		db.setWidget(panel);
		db.show();
		db.center();
		db.setModal(true);
		db.setAnimationEnabled(true);
	    
		tabPanel = new DecoratedTabPanel();
		initWidget(tabPanel);
    }
	
	public Widget getWidget() {
        return this;
	}
	
	public void addLogin(BaseView view) {
		panel.add(view.getWidget(), "Anmelden");
		panel.selectTab(0);
		panel.setSize("300px", "200px");
		tabPanel.setVisible(false);
	}

	public void addRegister(BaseView view) {
		panel.add(view.getWidget(), "Neues Konto anlegen");
	}

	public void reset() {
			
	}
	
	public void showAuthentication() {
		tabPanel.setVisible(false);
		db.show();
		db.center();
	}

	@Override
	public void addWorkitemManage(BaseView view) {
		tabPanel.add(view.getWidget(), "Workitem Verwalten");
		tabPanel.selectTab(0);
		tabPanel.setSize("800px", "600px");
	}
	
	public void addTagManage(BaseView view) {
		tabPanel.add(view.getWidget(), "Projekte Verwalten");
		tabPanel.setSize("800px", "600px");
	}
	
	public void addStatistic(BaseView view) {
		tabPanel.add(view.getWidget(), "Statistic");
		tabPanel.setSize("800px", "600px");
	}
	
	public void addTagShare(BaseView view) {
		tabPanel.add(view.getWidget(), "Zugang zu Projekt Freigeben");
		tabPanel.setSize("800px", "600px");
	}
	
	public void addWorkitemExport(BaseView view) {
		tabPanel.add(view.getWidget(), "Workitem Exportieren");
		tabPanel.setSize("800px", "600px");
	}

	public void addUserInfo() {
		FlowPanel flowPanel = new FlowPanel();
		tabPanel.add(flowPanel, "Logout");
	}
	
	@Override
	public void hideLogin() {
		tabPanel.setVisible(true);
		/*if(tabPanel.getWidgetCount()>0) {
			tabPanel.selectTab(0);
		}*/
		db.hide();
	}
	
	public DecoratedTabPanel getTabPanel() {
		return tabPanel;
	}
}

